<template>
	<div class="container">
		<van-nav-bar fixed left-text="返回" left-arrow :title="!isWeixin() ? '收益记录' : ''" @click-left="handleBack" />
		<div class="topHead-1">
			<span>累计收益（元）</span>
			<span>{{tgInfo.price}}</span>
		</div>
		<!-- <div class="" v-if="incomeRecordList.length>0">
			
		</div> -->
		<div class="recordList" v-if="incomeRecordList.length>0">
			<div class="recordList-item"  v-for="(item,index) in incomeRecordList">
				<div class="recordList-item-title">
					{{item.title}}
				</div>
				<div class="recordList-item-info">
					<span>订单金额：</span>
					<span>￥{{item.price}}</span>
				</div>
				<!-- <div class="recordList-item-info">
					<span>订单提成 ：</span>
					<span>￥{{item.tcprice}}</span>
				</div> -->
				<div class="recordList-item-info">
					<span>订单时间 ：</span>
					<span>{{dayjs.unix(item.addtime).format("YYYY-MM-DD HH:mm:ss")}}</span>
					
				</div>
			</div>
		</div>
		<div class="emptyUserList" v-else>
			<van-empty image-size="50" description="暂无收益记录" />
		</div>
	</div>
</template>

<script setup lang="ts">
	import {
		getCookie
	} from "@/utils/index";
	import {
		ref,
		reactive
	} from "vue";
	import {
		useRouter,
		useRoute
	} from "vue-router";
	import {
		isWeixin
	} from "@/utils/index";
	import {
		usertc, usertg
	} from "@/api/user";
	import dayjs from "dayjs"; 
	const tgInfo = ref();
	const router = useRouter();
	const route = useRoute();
	const handleBack = () => {
		if (history.state?.back) {
			router.back();
		} else {
			router.push("/user");
		}
	};
	const incomeRecordList = ref();
	const pageNo = ref(1);
	const pageSize = ref(15);
	const getIncomeRecord = async () => {
		let { data } = await usertc({
			uid: getCookie("token") ? Number(getCookie("token")) : "",
			// uid: 10766,
			pageNo: pageNo.value,
			pageSize: pageSize.value
		});
		incomeRecordList.value = data.data;
	};
	getIncomeRecord();
	// 获取推广信息
	const getTuiguang = async () => {
		let { data } = await usertg({ uid: getCookie("token") ? Number(getCookie("token")) : "" });
		// let { data } = await usertg({ uid: 10766});
		tgInfo.value = data;
	};
	getTuiguang()
</script>

<style scoped>
	.topHead-1 {
		margin-top: 46px;
		background: #1862D5;
		padding: 10px;
		filter: drop-shadow(2px 4px 6px #e5e5e5);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 150px;
		color: #fff;
	}

	.topHead-1 span:nth-child(2) {
		font-size: 30px;
		margin-top: 20px;
	}

	.recordList {
		padding: 10px;
	}

	.recordList-item {
		background: #fff;
		filter: drop-shadow(2px 4px 6px #e5e5e5);
		border-radius: 10px;
		padding: 20px;
		margin: 10px 0;
	}

	.recordList-item-title {
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 10px;
	}

	.recordList-item-info {
		margin: 2px 0;
	}

	.recordList-item-info span:first-child {
		color: #999;
	}

	.recordList-item-info span:nth-child(2) {
		color: #000;
		font-size: 16px;
	}
</style>